/**
 */
package org.mro.grib.model.files.secondEdition.dataRepresentations.impl;

import java.nio.ByteBuffer;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.mro.grib.model.files.secondEdition.dataRepresentations.DataRepresentationTemplate561;
import org.mro.grib.model.files.secondEdition.dataRepresentations.DataRepresentationsPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Data Representation Template561</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.mro.grib.model.files.secondEdition.dataRepresentations.impl.DataRepresentationTemplate561Impl#getReferenceValue <em>Reference Value</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.dataRepresentations.impl.DataRepresentationTemplate561Impl#getBinaryScaleFactor <em>Binary Scale Factor</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.dataRepresentations.impl.DataRepresentationTemplate561Impl#getDecimalScaleFactor <em>Decimal Scale Factor</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.dataRepresentations.impl.DataRepresentationTemplate561Impl#getNumberOfBitsUsedForEachPackedValue <em>Number Of Bits Used For Each Packed Value</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.dataRepresentations.impl.DataRepresentationTemplate561Impl#getPreProcessingParameter <em>Pre Processing Parameter</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class DataRepresentationTemplate561Impl extends EObjectImpl implements DataRepresentationTemplate561 {
	/**
	 * The default value of the '{@link #getReferenceValue() <em>Reference Value</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getReferenceValue()
	 * @generated
	 * @ordered
	 */
	protected static final int REFERENCE_VALUE_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getReferenceValue() <em>Reference Value</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getReferenceValue()
	 * @generated
	 * @ordered
	 */
	protected int referenceValue = REFERENCE_VALUE_EDEFAULT;

	/**
	 * The default value of the '{@link #getBinaryScaleFactor() <em>Binary Scale Factor</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBinaryScaleFactor()
	 * @generated
	 * @ordered
	 */
	protected static final short BINARY_SCALE_FACTOR_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getBinaryScaleFactor() <em>Binary Scale Factor</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBinaryScaleFactor()
	 * @generated
	 * @ordered
	 */
	protected short binaryScaleFactor = BINARY_SCALE_FACTOR_EDEFAULT;

	/**
	 * The default value of the '{@link #getDecimalScaleFactor() <em>Decimal Scale Factor</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDecimalScaleFactor()
	 * @generated
	 * @ordered
	 */
	protected static final short DECIMAL_SCALE_FACTOR_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getDecimalScaleFactor() <em>Decimal Scale Factor</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDecimalScaleFactor()
	 * @generated
	 * @ordered
	 */
	protected short decimalScaleFactor = DECIMAL_SCALE_FACTOR_EDEFAULT;

	/**
	 * The default value of the '{@link #getNumberOfBitsUsedForEachPackedValue() <em>Number Of Bits Used For Each Packed Value</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNumberOfBitsUsedForEachPackedValue()
	 * @generated
	 * @ordered
	 */
	protected static final byte NUMBER_OF_BITS_USED_FOR_EACH_PACKED_VALUE_EDEFAULT = 0x00;

	/**
	 * The cached value of the '{@link #getNumberOfBitsUsedForEachPackedValue() <em>Number Of Bits Used For Each Packed Value</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNumberOfBitsUsedForEachPackedValue()
	 * @generated
	 * @ordered
	 */
	protected byte numberOfBitsUsedForEachPackedValue = NUMBER_OF_BITS_USED_FOR_EACH_PACKED_VALUE_EDEFAULT;

	/**
	 * The default value of the '{@link #getPreProcessingParameter() <em>Pre Processing Parameter</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPreProcessingParameter()
	 * @generated
	 * @ordered
	 */
	protected static final int PRE_PROCESSING_PARAMETER_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getPreProcessingParameter() <em>Pre Processing Parameter</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPreProcessingParameter()
	 * @generated
	 * @ordered
	 */
	protected int preProcessingParameter = PRE_PROCESSING_PARAMETER_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected DataRepresentationTemplate561Impl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return DataRepresentationsPackage.Literals.DATA_REPRESENTATION_TEMPLATE561;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getReferenceValue() {
		return referenceValue;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setReferenceValue(int newReferenceValue) {
		int oldReferenceValue = referenceValue;
		referenceValue = newReferenceValue;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE561__REFERENCE_VALUE, oldReferenceValue, referenceValue));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public short getBinaryScaleFactor() {
		return binaryScaleFactor;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setBinaryScaleFactor(short newBinaryScaleFactor) {
		short oldBinaryScaleFactor = binaryScaleFactor;
		binaryScaleFactor = newBinaryScaleFactor;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE561__BINARY_SCALE_FACTOR, oldBinaryScaleFactor, binaryScaleFactor));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public short getDecimalScaleFactor() {
		return decimalScaleFactor;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDecimalScaleFactor(short newDecimalScaleFactor) {
		short oldDecimalScaleFactor = decimalScaleFactor;
		decimalScaleFactor = newDecimalScaleFactor;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE561__DECIMAL_SCALE_FACTOR, oldDecimalScaleFactor, decimalScaleFactor));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public byte getNumberOfBitsUsedForEachPackedValue() {
		return numberOfBitsUsedForEachPackedValue;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setNumberOfBitsUsedForEachPackedValue(byte newNumberOfBitsUsedForEachPackedValue) {
		byte oldNumberOfBitsUsedForEachPackedValue = numberOfBitsUsedForEachPackedValue;
		numberOfBitsUsedForEachPackedValue = newNumberOfBitsUsedForEachPackedValue;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE561__NUMBER_OF_BITS_USED_FOR_EACH_PACKED_VALUE, oldNumberOfBitsUsedForEachPackedValue, numberOfBitsUsedForEachPackedValue));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getPreProcessingParameter() {
		return preProcessingParameter;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setPreProcessingParameter(int newPreProcessingParameter) {
		int oldPreProcessingParameter = preProcessingParameter;
		preProcessingParameter = newPreProcessingParameter;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE561__PRE_PROCESSING_PARAMETER, oldPreProcessingParameter, preProcessingParameter));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE561__REFERENCE_VALUE:
				return getReferenceValue();
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE561__BINARY_SCALE_FACTOR:
				return getBinaryScaleFactor();
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE561__DECIMAL_SCALE_FACTOR:
				return getDecimalScaleFactor();
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE561__NUMBER_OF_BITS_USED_FOR_EACH_PACKED_VALUE:
				return getNumberOfBitsUsedForEachPackedValue();
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE561__PRE_PROCESSING_PARAMETER:
				return getPreProcessingParameter();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE561__REFERENCE_VALUE:
				setReferenceValue((Integer)newValue);
				return;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE561__BINARY_SCALE_FACTOR:
				setBinaryScaleFactor((Short)newValue);
				return;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE561__DECIMAL_SCALE_FACTOR:
				setDecimalScaleFactor((Short)newValue);
				return;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE561__NUMBER_OF_BITS_USED_FOR_EACH_PACKED_VALUE:
				setNumberOfBitsUsedForEachPackedValue((Byte)newValue);
				return;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE561__PRE_PROCESSING_PARAMETER:
				setPreProcessingParameter((Integer)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE561__REFERENCE_VALUE:
				setReferenceValue(REFERENCE_VALUE_EDEFAULT);
				return;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE561__BINARY_SCALE_FACTOR:
				setBinaryScaleFactor(BINARY_SCALE_FACTOR_EDEFAULT);
				return;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE561__DECIMAL_SCALE_FACTOR:
				setDecimalScaleFactor(DECIMAL_SCALE_FACTOR_EDEFAULT);
				return;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE561__NUMBER_OF_BITS_USED_FOR_EACH_PACKED_VALUE:
				setNumberOfBitsUsedForEachPackedValue(NUMBER_OF_BITS_USED_FOR_EACH_PACKED_VALUE_EDEFAULT);
				return;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE561__PRE_PROCESSING_PARAMETER:
				setPreProcessingParameter(PRE_PROCESSING_PARAMETER_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE561__REFERENCE_VALUE:
				return referenceValue != REFERENCE_VALUE_EDEFAULT;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE561__BINARY_SCALE_FACTOR:
				return binaryScaleFactor != BINARY_SCALE_FACTOR_EDEFAULT;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE561__DECIMAL_SCALE_FACTOR:
				return decimalScaleFactor != DECIMAL_SCALE_FACTOR_EDEFAULT;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE561__NUMBER_OF_BITS_USED_FOR_EACH_PACKED_VALUE:
				return numberOfBitsUsedForEachPackedValue != NUMBER_OF_BITS_USED_FOR_EACH_PACKED_VALUE_EDEFAULT;
			case DataRepresentationsPackage.DATA_REPRESENTATION_TEMPLATE561__PRE_PROCESSING_PARAMETER:
				return preProcessingParameter != PRE_PROCESSING_PARAMETER_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (referenceValue: "); //$NON-NLS-1$
		result.append(referenceValue);
		result.append(", binaryScaleFactor: "); //$NON-NLS-1$
		result.append(binaryScaleFactor);
		result.append(", decimalScaleFactor: "); //$NON-NLS-1$
		result.append(decimalScaleFactor);
		result.append(", numberOfBitsUsedForEachPackedValue: "); //$NON-NLS-1$
		result.append(numberOfBitsUsedForEachPackedValue);
		result.append(", preProcessingParameter: "); //$NON-NLS-1$
		result.append(preProcessingParameter);
		result.append(')');
		return result.toString();
	}

	/* (non-Javadoc)
	 * @see org.mro.grib.model.files.secondEdition.dataRepresentations.IDataRepresentation#initialise(java.nio.ByteBuffer)
	 */
	@Override
	public void initialise(ByteBuffer buffer) {
		referenceValue = buffer.getInt();
		binaryScaleFactor = buffer.getShort();
		decimalScaleFactor = buffer.getShort();
		numberOfBitsUsedForEachPackedValue = buffer.get();
		preProcessingParameter = buffer.getInt();
	}

} //DataRepresentationTemplate561Impl
